package com.sphd.emanu.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sphd.emanu.R;
import com.sphd.emanu.pojo.goods.Category;
import com.wzutils.L;

import java.util.List;

/**
 * @Author Hu
 * @Time 2017/4/28 --16:04.
 * @Email 87683202@qq.com
 */
public class GoodstypeAdapter extends BaseQuickAdapter<Category, BaseViewHolder> {
    boolean isCanDo;

    public GoodstypeAdapter(int layoutResId, List<Category> data, boolean isCanDo) {
        super(layoutResId, data);
        this.isCanDo = isCanDo;
    }

    @Override
    protected void convert(BaseViewHolder helper, Category item) {
        helper
                .setText(R.id.type_name, item.getName())
                .setText(R.id.type_no, "有" + item.getAmount() + "个商品")
                .addOnClickListener(R.id.type_edit)
                .setVisible(R.id.type_edit, isCanDo ? (helper.getAdapterPosition() == 0 ? false : true) : false);
    }


}
